home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Macintosh Tracker 1.20 / source / Tracker Client Folder / Core 18⁄March⁄1994 / CAboutWindow.c < prev    next >
Encoding:
Text File  |  1993-05-16  |  5.1 KB  |  147 lines  |  [TEXT/KAHL]

  1. tStringID (0x00800004)
  2. #define AlphaStringID (0x00800005)
  3. #define BetaStringID (0x00800006)
  4. #define NonFinalLocID (0x00800005)
  5.  
  6.  
  7. /* */            CAboutWindow::~CAboutWindow()
  8.     {
  9.         DeregisterIdler(this);
  10.         Application->AboutWindow = NIL; /* indicate we are gone */
  11.     }
  12.  
  13.  
  14. void            CAboutWindow::IAboutWindow(MyBoolean TheAutoFlag)
  15.     {
  16.         LongPoint                            Start;
  17.         LongPoint                            Extent;
  18.         CAboutWindowPicture*    AboutWindowPicture;
  19.  
  20.         GetRect(AboutWindowLocationID,&Start,&Extent);
  21.         IWindow(CenterRect(Extent,LongPointOf(screenBits.bounds.right
  22.             - screenBits.bounds.left,screenBits.bounds.bottom - screenBits.bounds.top)),
  23.             Extent,ModelessWindow,NoGrowable,NoZoomable);
  24.         if (TheAutoFlag)
  25.             {
  26.                 RegisterIdler(this,60);
  27.             }
  28.         AboutWindowPicture = new CAboutWindowPicture;
  29.         AboutWindowPicture->IAboutWindowPicture(this);
  30.         MomentOfInstantiation = TickCount();
  31.         AutoFlag = TheAutoFlag;
  32.         BecomeActiveWindow();
  33.     }
  34.  
  35.  
  36. void            CAboutWindow::DoIdle(long TimeSinceLastEvent)
  37.     {
  38.         if (AutoFlag)
  39.             {
  40.                 if (TickCount()-MomentOfInstantiation > ShowDelay)
  41.                     {
  42.                         GoAway();
  43.                         return;
  44.                     }
  45.             }
  46.         inherited::DoIdle(TimeSinceLastEvent);
  47.     }
  48.  
  49.  
  50. void            CAboutWindow::GoAway(void)
  51.     {
  52.         delete this;
  53.     }
  54.  
  55.  
  56. MyBoolean    CAboutWindow::DoMenuCommand(ushort MenuCommandValue)
  57.     {
  58.         if (MenuCommandValue == mFileClose)
  59.             {
  60.                 GoAway();
  61.                 return True;
  62.             }
  63.         return Application->DoMenuCommand(MenuCommandValue);
  64.     }
  65.  
  66.  
  67. void            CAboutWindow::EnableMenuItems(void)
  68.     {
  69.         MyEnableItem(mFileClose);
  70.         Application->EnableMenuItems();
  71.     }
  72.  
  73.  
  74. /********************************************************************************/
  75.  
  76.  
  77. void        CAboutWindowPicture::IAboutWindowPicture(CWindow* TheWindow)
  78.     {
  79.         LongPoint        Start;
  80.         LongPoint        Extent;
  81.  
  82.         GetRect(PictureLocationID,&Start,&Extent);
  83.         IViewRect(ZeroPoint,Extent,TheWindow,TheWindow);
  84.     }
  85.  
  86.  
  87. void        CAboutWindowPicture::DoUpdate(void)
  88.     {
  89.         PicHandle        Image;
  90.         Handle            Text;
  91.         Handle            VersRes;
  92.         Handle            Text2;
  93.         Handle            Text3;
  94.         LongPoint        VersLocStart;
  95.         LongPoint        VersLocExtent;
  96.         LongPoint        VBoxLocStart;
  97.         LongPoint        VBoxLocExtent;
  98.         short                ReleaseType;
  99.         short                NonReleaseVersion;
  100.  
  101.         ERROR(ResLoad == 0,PRERR(ForceAbort,"Automatic resource loading is disabled."));
  102.         SetUpPort();
  103.         Image = (PicHandle)GetResource('∫Cpc',PictureID);
  104.         ERROR(Image==NIL,PRERR(ForceAbort,"∫Cpc image resource not present."));
  105.         ERROR(ResErr != noErr,PRERR(ForceAbort,"Resource Error occurred."));
  106.         Window->LDrawPicture(Image,ZeroPoint,Extent);
  107.         ReleaseResource((Handle)Image);
  108.         Window->SetText(GetFontID("\pGeneva"),0,srcOr,9,0);
  109.         VersRes = GetResource('vers',1); /* get application version information */
  110.         ERROR(ResErr != noErr,PRERR(ForceAbort,"Resource Error occurred."));
  111.         HLock(VersRes);
  112.         ReleaseType = (*(uchar**)VersRes)[2]; /* pluck out release type */
  113.         NonReleaseVersion = ((*(uchar**)VersRes)[3] & 0x0f)
  114.             + 10*(((*(uchar**)VersRes)[3] & 0xf0) >> 4); /* pluck out non release version */
  115.         ERROR(VersRes==NIL,PRERR(ForceAbort,
  116.             "CImagePane::DoUpdate couldn't find 'vers' 1 resource."));
  117.         Text = PString2Handle(&(((uchar*)*VersRes)[6])); /* extract version string */
  118.         HUnlock(VersRes);
  119.         ReleaseResource(VersRes);
  120.         Text2 = GetCString(ApplicationVersionStringID); /* get "Version " */
  121.         Text3 = HStrCat(Text2,Text);
  122.         ReleaseHandle(Text);
  123.         ReleaseHandle(Text2); /* get rid of original handles */
  124.         GetRect(ApplicationVersionLocationID,&VersLocStart,&VersLocExtent);
  125.         VBoxLocStart.x = VersLocStart.x - 4;
  126.         VBoxLocStart.y = VersLocStart.y - 4;
  127.         VBoxLocExtent.x = VersLocExtent.x + 8;
  128.         VBoxLocExtent.y = VersLocExtent.y + 8;
  129.         Window->LEraseRect(VBoxLocStart,VBoxLocExtent);
  130.         Window->LTextBox(VersLocStart,VersLocExtent,Text3,JustifyLeft);
  131.         Window->LFrameRect(VBoxLocStart,VBoxLocExtent);
  132.         ReleaseHandle(Text3);
  133.         if (ReleaseType != FinalRelease)
  134.             {
  135.                 switch (ReleaseType)
  136.                     {
  137.                         case DevelopmentRelease:
  138.                             Text = GetCString(DevelopmentStringID);
  139.                             break;
  140.                         case AlphaRelease:
  141.                             Text = GetCString(AlphaStringID);
  142.                             break;
  143.                         case BetaRelease:
  144.                             Text = GetCString(BetaStringID);
  145.                             break;
  146.                         default:
  147.                             PRERR(F